<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link
      rel="stylesheet"
      href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
    />
    <script src="./js/jquery.js"></script>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      body {
        /* height: 900x; */
        position: relative;
      }
      .w {
        width: 980px;
        margin: 0 auto;
      }
      .header {
        width: 100%;
        height: 50px;
        background-color: rgb(202, 106, 221);
        text-align: center;
        font-size: 30px;
        color: aliceblue;
        line-height: 50px;
      }
      .banner {
        width: 100%;
        height: 300px;
        background-color: rgb(79, 119, 204);
        margin: 10px 0;
        font-size: 30px;
        color: aliceblue;
        /* text-align: center;
        line-height: 300px; */
        overflow: hidden;
      }
       .banner p{
     
        margin-top: 200px;
       }

      .content {
        width: 100%;
        height: 900px;
        background-color: rgb(100, 214, 209);
        margin: 10px 0;
        font-size: 30px;
        color: aliceblue;
        text-align: center;
        line-height: 300px;
      }
      .showcase {
        width: 100%;
        height: 300px;
        background-color: rgb(66, 231, 51);
        margin: 10px 0;
        font-size: 30px;
        color: aliceblue;
        text-align: center;
        line-height: 300px;
      }
      .miaosha {
        width: 100%;
        height: 300px;
        background-color: rgb(201, 177, 40);
        margin: 10px 0;
        font-size: 30px;
        color: aliceblue;
        text-align: center;
        line-height: 300px;
      }
      .bottom {
        width: 100%;
        height: 50px;
        background-color: rgb(194, 186, 78);
        text-align: center;
        font-size: 30px;
        color: aliceblue;
        line-height: 50px;
      }
      .slider-bar {
        width: 100px;
        height: 180px;
        background-color: rosybrown;
        text-align: center;
        font-size: 20px;
        color: aliceblue;
        line-height: 180px;
        position: absolute;
        right: 82px;
        bottom: 550px;
        display: none;
        cursor: pointer;
      }
      .daohang {
        display: flex;
        flex-direction: column;
        width: 150px;
        height: 200px;
        border: 5px solid rgb(209, 94, 157);
        justify-content: space-evenly;
        align-items: center;
        display: block;
        position: absolute;
        top: 52%;
        left: 0;
      }
      .daohang span {
        width: 100%;
        height: 49px;
        line-height: 49px;
        cursor: pointer;
        text-align: center;
        border-bottom: 1px solid rgb(190, 58, 157);
        display: block;
      }
      .acc {
        background-color: red;
      }
      /* .goBack {
        display: none;
      } */
    </style>
  </head>
  <body>
    <div class="header">
      <div class="w">头部</div>
    </div>

    <div>
      <div class="w">
        <div class="banner">
          <p>banner内容区域</p>
        </div>
      </div>
    </div>

    <div>
      <div class="w">
        <div class="showcase">橱窗专区</div>
      </div>
    </div>

    <div>
      <div class="w">
        <div class="miaosha">秒杀区域</div>
      </div>
    </div>

    <div>
      <div class="w">
        <div class="content">主体内容区域</div>
      </div>
    </div>

    <div class="bottom">
      <div class="w">底部内容区域</div>
    </div>

    <div class="slider-bar">
      <span class="goBack">返回顶部</span>
    </div>

    <div class="daohang">
      <span class="one">banner内容区域</span>
      <span class="two">橱窗专区</span>
      <span class="fir">秒杀区域</span>
      <span class="six">主体内容区域</span>
    </div>

    <script>
      $(function () {
        // let boxTo = $(".content").offset().top;
        
        // $(window).scroll(function () {
        //   //  console.log($(document).scrollTop());



        //   if ($(document).scrollTop() >= boxTo) {
        //     $(".slider-bar").fadeIn();
        //   } else {
        //     $(".slider-bar").fadeOut();
        //   }
        // });


        let bannerTo = $(".banner").offset().top;
        $(window).scroll(function () {
          // let miaoBox = $(".miaosha").offset().top;
          if ($(document).scrollTop() >= bannerTo) {
            $(".banner p").addClass("animate__animated animate__fadeInRight");
          } else {
            $(".banner p").removeClass("animate__animated animate__fadeInRight");
          }
        });

        console.log(bannerTo);
        $(".slider-bar").click(function () {
          $("html,body").stop().animate({ scrollTop: 0 }, 1000);
        });

        // $(".daohang span").hover(
        //   function () {
        //     $(this).css("backgroundColor", "red");
        //     $(this).css("color", "white");
        //   },
        //   function () {
        //     $(this).css("backgroundColor", "");
        //     $(this).css("color", "");
        //   }
        // );
        $(".daohang span").click(function () {
          let index = $(this).index();
          let current = $(".w").eq(index).offset().top;
          $("html,body").stop().animate({ scrollTop: current }, 1000);
          $(this).addClass("acc").siblings().removeClass();
        });
      });
    </script>
  </body>
</html>
